package ws

import "time"

type SessionReadIdleTimeout struct {
	session *Session
}

func (x *SessionReadIdleTimeout) OnTimeout() {
	x.session.sessionHandle.OnReadIdleTimeout(x.session)
}

func (x *SessionReadIdleTimeout) IsTimeout() bool {
	return x.session.lastReadAt.Add(x.session.readIdleTimeout).Before(time.Now())
}

func NewSessionReadIdleTimeout(session *Session) *SessionReadIdleTimeout {
	return &SessionReadIdleTimeout{
		session: session,
	}
}
